package com.goudan.demo.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.goudan.demo.entity.User;
import com.goudan.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 员工表 前端控制器
 * </p>
 *
 * @author 李苟蛋
 * @since 2021-04-03
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping("addUser")
    public void addEmployee(User user) {
        user.setUserName("zhangsan");
        user.setUserAge(15);
        user.setUserPhone("17611028882");
        userService.save(user);
    }

    @RequestMapping("selectUser")
    public List<User> selectEmployee(User user) {
        Page<User> page = new Page<>(1, 5);
        QueryWrapper<User> wrapper = Wrappers.query();
        wrapper.eq("USER_NAME", "zhangsan");
        Page<User> userPage = userService.page(page, wrapper);
        return userPage.getRecords();
    }
}

